﻿using SD.IdentitySystem;
using SD.IdentitySystem.IAppService.Interfaces;
using SD.Infrastructure.Membership;
using SD.IOC.Core.Mediators;
using SlamDunk.MES.DataDrive.Common;
using System.Configuration;

namespace SlamDunk.MES.DataDrive.Bussiness
{
    /// <summary>
    /// 数据库配置
    /// </summary>
    public class DataDriveConfig : IDataDriveConfig
    {
        public const string RealgoalName = "Realgoal.MOM.v1.0";
        public const string IdentityName = "SD.IdentitySystem.MOM.v1.0";

        public const string RealgoalConnectionStrings = "Data Source=.;Initial Catalog=Realgoal.MOM.v1.0;User Id=sa;Password=realgoal123!;MultipleActiveResultSets=true;Connect Timeout=900;";
        public const string IdentityConnectionStrings = "Data Source=.;Initial Catalog=SD.IdentitySystem.MOM.v1.0;User Id=sa;Password=realgoal123!;MultipleActiveResultSets=true;Connect Timeout=900;";


        /// <summary>
        /// 初始化配置
        /// </summary>
        public void InitConfig()
        {
            string loginId = ConfigurationManager.AppSettings["LoginId"];
            string password = ConfigurationManager.AppSettings["Password"];

            IAuthenticationContract authenticationContract = ResolveMediator.Resolve<IAuthenticationContract>();
            LoginInfo loginInfo = authenticationContract.Login(loginId, password);
            MembershipMediator.SetLoginInfo(loginInfo);
        }
    }
}
